JavaScriptַȫ 
JSԴ

1.Asc(x),Chr(x):תַַ

2Filter:Ѱַеضַ

ʽv=filter(x,s[,include[,compare]])

ʵ

Dim x()={"kjwang","wangkj","peter"}

Dim v

v=filter(x,"kj") 'v(0)="kjwang",v(1)="wangkj"

v=filter(x,"kj",false) 'v(0)="peter"

v=filter(x,"kj",true,vbTextCompare) 'ִСдѰ 

3.InStr:Ѱַλ(InstrRev:Ѱַ

ʽ

v=instr(x,y) 'xַ1ַҳyֵַλ

v=instr(n,x,y) 'xַnַҳyֵַλ

ʽ

v=InstrRev(x,s[,n[,Compare]])

4Join:ַ

ʽv=join(x[,d]dΪַָ

5Len(x):ַxĳ

ʽv=len(x)

6.Left(x,n):ַxnַ(ӦRight(x,n))

7Mid:ȡַxмַ

ʽv=mid(x,n,m)

8LTrim(x),RTim(x),Trim(x)ȥհַ

9.Replace:ַȡ

ʽv=Replace(x,s,r)

ʵx="i saw a saw a saw"

v=replace(x,"saw","so") 'v="i so a so a so"

10.Split:ַָ

ʽv=split(s[,d])

ʵv=split("vb.net,iis6.0,asp.net",",")

'v(0)="vb.net",v(1)="iis6.0",v(2)="asp.net"

11.StrReverse:תַ

ʵv=strreverse("kjwang") 'v="gnawjk"

12.UCase(x),LCase(x):任ӢĸĴСд

ʵx="hello,VB!"

v=UCase(x) 'v="HELLO,VBģ" 
1.ȡʱ

1DateValue(x),TimeValue(x)

ʽv=DateValue(x) :ȡġڡ

v=timevalue(x) '

2Year(x),Month(x),Day(x)

ʽv=Year(x)

v=Month(x)

v=Day(x)

Hour(x),Minute(x),Second(x):ȡʱ֣

3DateSerial(Y,M,D):ϲꡢ¡ճΪ

ʵDim v

v=DateSerial(1996,10,5) 'v=1996/10/5

TimeSerial(H,M,S):ϲʱ֡Ϊʱ

2.Now:ȡϵͳʱ

ʽv=now

3.Timer:賿120000AM

ʽv=timer

4.DatePart(p,x):ȡꡢ¡յȸֵֵ

ʵDim X=#2/10/1996 16:45:30#

v=DatePart("yyyy",X) 'v=1996

v=DatePart("m",X) 'v=2

v=DatePart("d",X) 'v=10

v=DatePart("h",X) 'v=16ʱ

v=DatePart("n",X) 'v=45

v=DatePart("s",X) 'v=30

v=DatePart("q",X) 'v=1һ

v=DatePart("y",X) 'v=41죨1996ĵ41죩

v=DatePart("ww",X) 'v=6ܣ1996ĵ6ܣ

v=DatePart("w",X) 'v=76ܵĵ7죬

5DateAdd(p,n,x):Ӽʱʱ

ʽv=DateAdd(p,n,x) 'pֵͬ磺"yyyy""m"

ʵDim x=#1/31/1996 16:45:30#

v=dateadd("yyyy",-3,x) '3꣬v=1993/1/31 16:45:30

6.DateDiff(p,x1,x2):ʱĲֵ 'pֵͬ

ʵdim x1=#12/31/1996 16:45:30#

x2=#2/10/1997 9:30:50#

v=datediff("yyyy",x1,x2) 'v=1 

7FormatDateTime:ʱĸʽ

ʽv=formatdateyime(x[,ڸʽ])

ڸʽֵDateFormat.GeneralDateDateFormat.LongDate

DateFotmat.ShortDateDateFormat.LongTimeDateFormat.ShortTime

8.MonthName:·

ʵv=monthname(5) 'v=""

9.WeekDayName:ơ÷ͬ8.

 

/*
******************************************
                        ַ                                 
******************************************
*/

/*
===========================================
//ȥߵĿո
===========================================

*/
String.prototype.LTrim = function()
{
        return this.replace(/(^\s*)/g, "");
}


/*
===========================================
//ȥұߵĿո
===========================================
*/
String.prototype.Rtrim = function()
{
        return this.replace(/(\s*$)/g, "");
}

 

/*
===========================================
//ȥǰո
===========================================
*/
String.prototype.Trim = function()
{
        return this.replace(/(^\s*)|(\s*$)/g, "");
}

/*
===========================================
//õߵַ
===========================================
*/
String.prototype.Left = function(len)
{

        if(isNaN(len)||len==null)
        {
                len = this.length;
        }
        else
        {
                if(parseInt(len)<0||parseInt(len)>this.length)
                {
                        len = this.length;
                }
        }
        
        return this.substr(0,len);
}


/*
===========================================
//õұߵַ
===========================================
*/
String.prototype.Right = function(len)
{

        if(isNaN(len)||len==null)
        {
                len = this.length;
        }
        else
        {
                if(parseInt(len)<0||parseInt(len)>this.length)
                {
                        len = this.length;
                }
        }
        
        return this.substring(this.length-len,this.length);
}


/*
===========================================
//õмַ,ע0ʼ
===========================================
*/
String.prototype.Mid = function(start,len)
{
        return this.substr(start,len);
}


/*
===========================================
//ַһַ:λô0ʼ
===========================================
*/
String.prototype.InStr = function(str)
{

        if(str==null)
        {
                str = "";
        }
        
        return this.indexOf(str);
}

/*
===========================================
//ַﷴһַ:λ0ʼ
===========================================
*/
String.prototype.InStrRev = function(str)
{

        if(str==null)
        {
                str = "";
        }
        
        return this.lastIndexOf(str);
}

 

/*
===========================================
//ַӡ
===========================================
*/
String.prototype.LengthW = function()
{
        return this.replace(/[^\x00-\xff]/g,"**").length;
}

/*
===========================================
//ǷȷIPַ
===========================================
*/
String.prototype.isIP = function()
{

        var reSpaceCheck = /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/;

        if (reSpaceCheck.test(this))
        {
                this.match(reSpaceCheck);
                if (RegExp.$1 <= 255 && RegExp.$1 >= 0 
                 && RegExp.$2 <= 255 && RegExp.$2 >= 0 
                 && RegExp.$3 <= 255 && RegExp.$3 >= 0 
                 && RegExp.$4 <= 255 && RegExp.$4 >= 0) 
                {
                        return true;     
                }
                else
                {
                        return false;
                }
        }
        else
        {
                return false;
        }
   
}


/*
===========================================
//Ƿȷĳ
===========================================
*/
String.prototype.isLongDate = function()
{
        var r = this.replace(/(^\s*)|(\s*$)/g, "").match(/^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})$/); 
        if(r==null)
        {
                return false; 
        }
        var d = new Date(r[1], r[3]-1,r[4],r[5],r[6],r[7]); 
        return (d.getFullYear()==r[1]&&(d.getMonth()+1)==r[3]&&d.getDate()==r[4]&&d.getHours()==r[5]&&d.getMinutes()==r[6]&&d.getSeconds()==r[7]);

}

/*
===========================================
//ǷȷĶ
===========================================
*/
String.prototype.isShortDate = function()
{
        var r = this.replace(/(^\s*)|(\s*$)/g, "").match(/^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/); 
        if(r==null)
        {
                return false; 
        }
        var d = new Date(r[1], r[3]-1, r[4]); 
        return (d.getFullYear()==r[1]&&(d.getMonth()+1)==r[3]&&d.getDate()==r[4]);
}

/*
===========================================
//Ƿȷ
===========================================
*/
String.prototype.isDate = function()
{
        return this.isLongDate()||this.isShortDate();
}

/*
===========================================
//Ƿֻ
===========================================
*/
String.prototype.isMobile = function()
{
        return /^0{0,1}13[0-9]{9}$/.test(this);
}

/*
===========================================
//Ƿʼ
===========================================
*/
String.prototype.isEmail = function()
{
        return /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/.test(this);
}

/*
===========================================
//Ƿʱ(й)
===========================================
*/

String.prototype.isZipCode = function()
{
        return /^[\\d]{6}$/.test(this);
}

/*
===========================================
//Ƿк
===========================================
*/
String.prototype.existChinese = function()
{
        //[\u4E00-\u9FA5]h֩o[\uFE30-\uFFA0]ȫǷ̖
        return /^[\x00-\xff]*$/.test(this);
}

/*
===========================================
//ǷǺϷļ/Ŀ¼
===========================================
*/
String.prototype.isFileName = function()
{
        return !/[\\\/\*\?\|:"<>]/g.test(this);
}

/*
===========================================
//ǷЧ
===========================================
*/
String.prototype.isUrl = function()
{
        return /^http[s]?:\/\/([\w-]+\.)+[\w-]+([\w-./?%&=]*)?$/i.test(this);
}


/*
===========================================
//ǷЧ֤(й)
===========================================
*/
String.prototype.isIDCard = function()
{
        var iSum=0;
        var info="";
        var sId = this;

        var aCity={11:"",12:"",13:"ӱ",14:"ɽ",15:"ɹ",21:"",22:"",23:"",31:"Ϻ",32:"",33:"㽭",34:"",35:"",36:"",37:"ɽ",41:"",42:"",43:"",44:"㶫",45:"",46:"",50:"",51:"Ĵ",52:"",53:"",54:"",61:"",62:"",63:"ຣ",64:"",65:"½",71:"̨",81:"",82:"",91:""};

        if(!/^\d{17}(\d|x)$/i.test(sId))
        {
                return false;
        }
        sId=sId.replace(/x$/i,"a");
        //Ƿ
        if(aCity[parseInt(sId.substr(0,2))]==null)
        {
                return false;
        }

        var sBirthday=sId.substr(6,4)+"-"+Number(sId.substr(10,2))+"-"+Number(sId.substr(12,2));

        var d=new Date(sBirthday.replace(/-/g,"/"))
        
        //Ƿ
        if(sBirthday!=(d.getFullYear()+"-"+ (d.getMonth()+1) + "-" + d.getDate()))
        {
                return false;
        }
        for(var i = 17;i>=0;i--) 
        {
                iSum += (Math.pow(2,i) % 11) * parseInt(sId.charAt(17 - i),11);
        }

        if(iSum%11!=1)
        {
                return false;
        }
        return true;

}

/*
===========================================
//ǷЧĵ绰(й)
===========================================
*/
String.prototype.isPhoneCall = function()
{
        return /(^[0-9]{3,4}\-[0-9]{3,8}$)|(^[0-9]{3,8}$)|(^\([0-9]{3,4}\)[0-9]{3,8}$)|(^0{0,1}13[0-9]{9}$)/.test(this);
}


/*
===========================================
//Ƿ
===========================================
*/
String.prototype.isNumeric = function(flag)
{
        //֤Ƿ
        if(isNaN(this))
        {

                return false;
        }

        switch(flag)
        {

                case null:        //
                case "":
                        return true;
                case "+":        //
                        return                /(^\+?|^\d?)\d*\.?\d+$/.test(this);
                case "-":        //
                        return                /^-\d*\.?\d+$/.test(this);
                case "i":        //
                        return                /(^-?|^\+?|\d)\d+$/.test(this);
                case "+i":        //
                        return                /(^\d+$)|(^\+?\d+$)/.test(this);                        
                case "-i":        //
                        return                /^[-]\d+$/.test(this);
                case "f":        //
                        return                /(^-?|^\+?|^\d?)\d*\.\d+$/.test(this);
                case "+f":        //
                        return                /(^\+?|^\d?)\d*\.\d+$/.test(this);                        
                case "-f":        //
                        return                /^[-]\d*\.\d$/.test(this);                
                default:        //ȱʡ
                        return true;                        
        }
}

/*
===========================================
//Ƿɫ(#FFFFFFʽ)
===========================================
*/
String.prototype.IsColor = function()
{
        var temp        = this;
        if (temp=="") return true;
        if (temp.length!=7) return false;
        return (temp.search(/\#[a-fA-F0-9]{6}/) != -1);
}

/*
===========================================
//תȫ
===========================================
*/
String.prototype.toCase = function()
{
        var tmp = "";
        for(var i=0;i<this.length;i++)
        {
                if(this.charCodeAt(i)>0&&this.charCodeAt(i)<255)
                {
                        tmp += String.fromCharCode(this.charCodeAt(i)+65248);
                }
                else
                {
                        tmp += String.fromCharCode(this.charCodeAt(i));
                }
        }
        return tmp
}

/*
===========================================
//ַHtml
===========================================
*/
String.prototype.toHtmlEncode = function()
{
        var str = this;

        str=str.replace(/&/g,"&amp;");
        str=str.replace(/</g,"&lt;");
        str=str.replace(/>/g,"&gt;");
        str=str.replace(/\'/g,"&apos;");
        str=str.replace(/\"/g,"&quot;");
        str=str.replace(/\n/g,"<br>");
        str=str.replace(/\ /g,"&nbsp;");
        str=str.replace(/\t/g,"&nbsp;&nbsp;&nbsp;&nbsp;");

        return str;
}

/*
===========================================
//ת
===========================================
*/
String.prototype.toDate = function()
{
        try
        {
                return new Date(this.replace(/-/g, "\/"));
        }
        catch(e)
        {
                return null;
        }
}

